package org.deng.learn.webflux.dao;

import org.deng.learn.webflux.entity.User;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;

/**
 * @author 邓力宾
 * @date 2020/12/18 15:25
 * @desc
 */
@Repository
public interface UserRepository extends ReactiveMongoRepository<User, String> {

    /**
     * 根据年龄查询 jpa 自动生成查询语句
     * @param start
     * @param end
     * @return
     */
    Flux<User> findByAgeBetween(int start, int end);

    @Query("{'age': {'$gte': 20, '$lte': 30}}")
    Flux<User> oldUser();
}
